<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_number')->unique()->comment("订单流水号");
            $table->integer('customer_id')->comment("下单用户ID");
            $table->json('address')->comment("收货地址");
            $table->decimal('total_account')->comment("订单总金额");
            $table->integer('total_amount')->comment("订单总数量");
            $table->string('remark')->nullable()->comment("订单备注");
            $table->dateTime('paid_at')->nullable()->comment("支付时间");
            $table->tinyInteger('payment_method')->nullable()->comment("支付方式");
            $table->string('payment_no')->nullable()->comment("支付平台订单号");
            $table->string('refund_status')->default(\App\Models\Order::REFUND_STATUS_PENDING)->comment("退款状态");
            $table->string('refund_no')->nullable()->comment("退款单号");
            $table->boolean('closed')->default(false)->comment("订单是否关闭");
            $table->boolean('reviewed')->default(false)->comment("订单是否评价");
            $table->string('ship_status')->default(\App\Models\Order::SHIP_STATUS_PENDING)->comment("物流状态");
            $table->json('ship_data')->nullable()->comment("物流数据");
            $table->json('extra')->nullable()->comment("额外数据");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
